//
//  FQIMineViewController.swift
//  YQInformation
//
//  Created by Max on 2017/11/2.
//  Copyright © 2017年 com.vector. All rights reserved.
//

import UIKit

class FQIMineViewController: FQIViewController , UITableViewDelegate, UITableViewDataSource {

    @IBOutlet weak var tableView: UITableView!
   
   override func viewDidLoad() {
        super.viewDidLoad()
    
    tableView.tableFooterView = UIView()
    
    self.title = "我的"
    
    if self.navigationItem.leftBarButtonItem != nil {
        let btn = UIButton(type: UIButtonType.custom)
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(customView: btn)
        
    }


    }
  

    func numberOfSections(in tableView: UITableView) -> Int {
        
        return 3
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        
        if section == 0 {
            
            return 2
            
        }else if section == 1{
            
            
            return 3
            
        }else {
        
        
            return 2
            
        }
    }

    func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
        
        if section == 0 {
            
            return ""
        }else if section == 1 {
            
            return " "
            
        }else {
        
            return " "
            
        }
        
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        var cell = UITableViewCell()
        
        switch indexPath.section {
            
        case 0:
            cell = tableView.dequeueReusableCell(withIdentifier: FQIMineCell.name,for: indexPath)
        
            if let mineCell = cell as? FQIMineCell {
                mineCell.accessoryType = .disclosureIndicator
                if indexPath.row == 0 {
                    mineCell.titleButton.setImage(UIImage(named:"15"), for: .normal)
                    mineCell.titleLabel?.text = "打开推送"

                }else {
                
                    mineCell.titleButton.setImage(UIImage(named:"16"), for: .normal)
                    mineCell.titleLabel?.text = "关注微信"
                       mineCell.focusLabel.isHidden = false
                    
                    
                }
                
            }
        
        case 1:
            cell = tableView.dequeueReusableCell(withIdentifier: FQIMineCell.name,for: indexPath)

            if let mineCell = cell as? FQIMineCell {
                mineCell.accessoryType = .disclosureIndicator

                if indexPath.row == 0 {
                    mineCell.titleButton.setImage(UIImage(named:"17"), for: .normal)
                    mineCell.titleLabel?.text = "用户反馈"
                    
                }else if indexPath.row == 1 {
                    mineCell.titleButton.setImage(UIImage(named:"18"), for: .normal)
                    mineCell.titleLabel?.text = "常见问题"
                    
                }else {
                    mineCell.titleButton.setImage(UIImage(named:"19"), for: .normal)
                    mineCell.titleLabel?.text = "分享给朋友"
                    
                }
                
            }
            
        case 2:
            cell = tableView.dequeueReusableCell(withIdentifier: FQIMineCell.name,for: indexPath)

            if let mineCell = cell as? FQIMineCell {
                mineCell.accessoryType = .disclosureIndicator

                if indexPath.row == 0 {
                    mineCell.titleButton.setImage(UIImage(named:"20"), for: .normal)
                    mineCell.titleLabel?.text = "关于我们"
                    
                }else {
                    mineCell.titleButton.setImage(UIImage(named:"21"), for: .normal)
                    mineCell.titleLabel?.text = "设置"
                }
                
            }
            
        
        default:
            break
        }
        
        return cell
    }

    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        
        if indexPath.section == 0 {
        
        
            if indexPath.row == 0 {
            
            }else {
            
            }

        }else if indexPath.section == 1 {
        
            if indexPath.row == 0 {
                if let v = FQIFeedbackViewController.create() as? FQIFeedbackViewController {
                
                    self.hidesBottomBarWhenPushed = true
                    self.navigationController?.pushViewController(v, animated: true)
                    self.hidesBottomBarWhenPushed = false
                }
            }else if indexPath.row == 1 {
                
            }else {
            
            }
        }else {
            if indexPath.row == 0 {
                
              if let v = FQIAboutUsViewController.create() as? FQIAboutUsViewController {
                self.hidesBottomBarWhenPushed = true
                self.navigationController?.pushViewController(v, animated: true)
                self.hidesBottomBarWhenPushed = false
                
                }
                
                
                
            }else {
                
            }
        
        
        }
        
    }
    
    
    
    @IBAction func activityAction(_ sender: Any) {
        
        if let v = FQIActivityViewController.create() as? FQIActivityViewController {
         
            v.hidesBottomBarWhenPushed = true
            self.navigationController?.pushViewController(v, animated: true)
        }
    }
    
    
    
    
    
    @IBAction func messageAction(_ sender: Any) {
        
        if let v = FQIMessageViewController.create() as? FQIMessageViewController {
       
            v.hidesBottomBarWhenPushed = true
            self.navigationController?.pushViewController(v, animated: true)
        }
        
        
    
    }

  
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

}
